package com.example.base.net

import com.example.base.entity.*
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Query

interface ApiServer {
    //用协程调用，所以定义的方法为挂起函数
    @POST(Cons.LOGIN_URL)
    suspend fun login(@Body body:RequestBody):UserEntityResult

    @POST(Cons.REGISTER_URL)
    suspend fun register(@Body body: RequestBody):UserEntityResult

    @GET(Cons.BANNER_URL)
    suspend fun banner():BannerEntityResult

    @GET(Cons.CATEGORY_URL)
    suspend fun category():CategoryEntityResult

    @GET(Cons.GOODS_URL)
    suspend fun goods(@Query("category_id")categoryId:Int,
                      @Query("currentPage") currentPage:Int,
                      @Query("pageSize")pageSize:Int):GoodsEntityResult

    @GET(Cons.DETAIL_URL)
    suspend fun detail(@Query("goods_id")goodsId:Int):DetailEntityResult

    @POST(Cons.ADDCAR_URL)
    suspend fun addCar(@Body body: RequestBody):ResultEntity


    @GET(Cons.SELECTCAR_URL)
    suspend fun selectCar():CarEntityResult

    @POST(Cons.DELETECAR_URL)
    suspend fun deleteCar(@Body body: RequestBody):ResultEntity

    @POST(Cons.ADDRESS_URL)
    suspend fun address(@Query("address")address:String):ResultEntity
    @Multipart
    @POST(Cons.ICON_URL)
    suspend fun updateIcon(@Part part:MultipartBody.Part):ResultEntity
}